package tau_sadna.tau_map;

import android.graphics.Color;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.RoundRectShape;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

public class ResultsView extends LinearLayout {

	public ResultsView(MainActivity main, Result[] results) {
		super(main);
		int i;
		LinearLayout.LayoutParams horizLine = new LinearLayout.LayoutParams(
				LayoutParams.MATCH_PARENT, 1);
		horizLine.setMargins(20,0,20,0);
		LinearLayout.LayoutParams resultText = new LinearLayout.LayoutParams(
				LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
		resultText.setMargins(20, 10, 20, 10);
		setOrientation(VERTICAL);
		setBackgroundDrawable(new RectBackground());
		if (results == null) {
			TextView noResults = new TextView(main);
			noResults.setTextSize(20);
			noResults.setLayoutParams(resultText);
			noResults.setText("No Results");
			addView(noResults);
			return;
		}
		for (i = 0;i < results.length;i++) { 
			ResultLineView line = new ResultLineView(main,results[i]);
			line.setLayoutParams(resultText);
			addView(line);
			if (i != results.length-1) { //not the last result
				View separator = new View(main);
				separator.setBackgroundColor(Color.DKGRAY);
				addView(separator,horizLine);
			}
		}
	}

}
